package com.cmy.test.mvp.ui.list

import android.view.LayoutInflater
import android.view.ViewGroup
import com.cmy.framework_base.basics.viewholder.BaseViewHolder
import com.cmy.framework_base.basics.viewholder.HolderContext
import com.cmy.framework_base.basics.viewholder.IType
import com.cmy.test.mvp.databinding.ItemTest1Binding


/**
 * @name:
 *  Test1ViewHolder
 * @package:
 *  com.cmy.test.mvp.ui.list
 * @date:
 *  2023/4/614:38
 * @author
 *    cmy
 * @description
 *  列表测试数据
 */
class Test1ViewHolder constructor(private val binding : ItemTest1Binding): BaseViewHolder(binding.root){


    override fun onBindData(data: IType) {
       val bean = data as Test1ListData
        binding.text.text = bean.name
    }

    /**
     * 适配器的实现
     */
     class Test1Factory : Factory {
        override fun onCreateViewHolder(
            holderContext: HolderContext?,
            parent: ViewGroup,
            viewType: Int
        ): BaseViewHolder {
            val inflater = LayoutInflater.from(parent.context)
            val binding =   ItemTest1Binding.inflate(inflater)

            return Test1ViewHolder(binding)
        }

        override fun getType(): String = "test1"
    }
}


